<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'majorList.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link href="css/mytablecss.css" rel="stylesheet" type="text/css" />
</head>

<body>
	<h3 style="padding:15px;">专业列表</h3>
	<a class="mybtn f-r mgr" id="add_major">添加专业</a>
	
	<div class="pd-20" style="margin-top: 50">
		<div class="mt-20">
			<table
				class="table table-border table-bordered table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
						<!-- <th width="80">序号</th> -->
						<th width="200">专业名称</th>
						<th width="200">创建人名称</th>
						<th width="200">创建时间</th>
						<!-- <th width="100">操作</th> -->
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${requestScope.majorList}" var="major">
						<tr>
							<td><c:out value="${major.major}"></c:out></td>
							<td><c:out value="${major.name}"></c:out></td>
							<td><c:out value="${major.create_time}"></c:out></td>
							<!-- <td class="td-manage"><a title="编辑" class="ml-5 edit"
								style="text-decoration:none" onclick="edit(this)"> <i
									class="Hui-iconfont">&#xe6df;</i></a> <a
								style="text-decoration:none" class="ml-5"
								onClick="alterPassword(this)" title="修改密码"> <i
									class="Hui-iconfont">&#xe63f;</i></a> <a title="删除"
								href="javascript:;" onclick="remove(this)" class="ml-5"
								style="text-decoration:none"> <i class="Hui-iconfont">&#xe6e2;</i></a>
							</td> -->
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
	</div>

	<div id="bcg_editor" class="editor_background">
		<form id="add_major_form" class="editor_main form form-horizontal">
			<legend> 专业信息窗口 </legend>
			<div style="margin-left: 21%;">
				<div class="row" style="margin-top: 25px;">
					<label class="form-label col-xs-4 col-sm-3">专业名称:</label>
					<div class="formControls col-xs-8 col-sm-9 input_manager">
						<input id="i_major" name="i_major" class="input-text"
							type="text">
					</div>
				</div>
				<br />
				<br />

				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input id="btn_ensure" class="btn btn-primary f-l btn_ensure"
						style="width: 75px;" value="确认"> <input id="btn_exit"
						class="btn btn-primary f-l btn_exit" value="取消">
				</div>
			</div>
		</form>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		$('.table-sort').dataTable({
			"aaSorting" : [ [ 0, "asc" ] ],//默认第几个排序
			"bStateSave" : true,//状态保存 
			"bRetrieve" : true,
			"aoColumnDefs" : [
			//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
			//{"orderable":false,"aTargets":[7]}// 制定列不参与排序
			]
		});
	});
	//编辑窗口取消按钮
	$(function() {
		$('#btn_exit').on('click', function() {
			$("#i_major").val("");
			$('#bcg_editor').hide();
		});

	});
	//编辑窗口确认按钮
	$(function() {
		$('#btn_ensure').on('click', function() {
			//验证表单信息
			if (!$("#add_major_form").valid()) {
				return false;
			}
			if (!confirm("确认增加?")) {
				return false;
			}
			//提交修改信息逻辑
			var majorInfo = {
				major : $("#i_major").val(),
			};
			/* $.ajax({
			"data" : majorInfo,
			"url" : "",
			"type" : "POST",
			"success" : function(result) {
				var resultJson = JSON.parse(result);
				if (resultJson.code == "200") {
					alert("修改成功");
					//刷新页面
					$.post("./CategoryListServlet?method=major", function(data) {
						$('#content').html(data);
						
					});
					
				} else {
					alert("修改失败");
				}
			}
			}); */
			console.log(majorInfo);
			
		});
	});

	//删除按钮
	function remove(widget) {
		//删除数据逻辑
	}
	
	//增加专业按钮
	$(function() {
		$("#add_major").on("click", function() {
			$('#bcg_editor').show();
		});
	});

	//添加科目表单
	$("#add_major_form").validate({
		rules : {
			i_major : {
				required : true,
				maxlength : 20
			},
		},
		onkeyup : false,
		focusCleanup : true,
		success : "valid"
	});
</script>
</html>
